package com.ipan.builder.ext.entity;

/**
 * 自定义字段配置信息
 * <pre>
 * 主要针对JDBC、Mybatis开发时候使用。
 * </pre>
 * @author iPan
 * @version 2015-1-24
 */
public class DefColumnCfg {

	/** 实体字段名字 */
	private String columnName = "";

	/** 实体字段类型 */
	private Class<?> columnType = String.class;

	/** @Column name */
	private String name = "";

	/** @Column length */
	private int length = 255;
	
	/** @Column nullable */
	private boolean nullable = true;
	
	/** @Transient */
	private boolean isTransient = false; // 是否含有@Transient注解

	/** @Build searchColumn */
	private boolean searchColumn = false;	// 查询字段
	
	/** @Build listColumn */
	private boolean listColumn = false;		// 列表字段
	
	/** @Build submitColumn */
	private boolean submitColumn = false;	// 表单提交字段
	
	/** @Build hiddenColumn */
	private boolean hiddenColumn = false;	// 表单隐藏字段
	
	/** @Build comment */
	private String comment = "";			// 数据库字段注释
	
	/** 实体类配置 */
	private DefEntityCfg entityCfg;

	public DefColumnCfg(DefEntityCfg entityCfg) {
		this.entityCfg = entityCfg;
	}

	public DefColumnCfg(DefEntityCfg entityCfg, String columnName, Class<?> columnType) {
		this.entityCfg = entityCfg;
		this.columnName = columnName;
		this.columnType = columnType;
	}

	public String getColumnName() {
		return columnName;
	}

	public void setColumnName(String columnName) {
		this.columnName = columnName;
	}

	public Class<?> getColumnType() {
		return columnType;
	}

	public void setColumnType(Class<?> columnType) {
		this.columnType = columnType;
	}
	
	public boolean isStringColumnType() {
		return String.class.isAssignableFrom(this.columnType);
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getLength() {
		return length;
	}

	public void setLength(int length) {
		this.length = length;
	}

	public boolean isSearchColumn() {
		return searchColumn;
	}

	public void setSearchColumn(boolean searchColumn) {
		this.searchColumn = searchColumn;
	}

	public boolean isListColumn() {
		return listColumn;
	}

	public void setListColumn(boolean listColumn) {
		this.listColumn = listColumn;
	}

	public boolean isSubmitColumn() {
		return submitColumn;
	}

	public void setSubmitColumn(boolean submitColumn) {
		this.submitColumn = submitColumn;
	}

	public boolean isHiddenColumn() {
		return hiddenColumn;
	}

	public void setHiddenColumn(boolean hiddenColumn) {
		this.hiddenColumn = hiddenColumn;
	}

	public String getComment() {
		return comment;
	}

	public void setComment(String comment) {
		this.comment = comment;
	}

	public boolean isTransient() {
		return isTransient;
	}

	public void setTransient(boolean isTransient) {
		this.isTransient = isTransient;
	}
	
	public boolean isDateType() {
		return java.util.Date.class.isAssignableFrom(this.columnType);
	}

	public DefEntityCfg getEntityCfg() {
		return entityCfg;
	}

	public void setEntityCfg(DefEntityCfg entityCfg) {
		this.entityCfg = entityCfg;
	}

	public boolean isNullable() {
		return nullable;
	}

	public void setNullable(boolean nullable) {
		this.nullable = nullable;
	}

	@Override
	public String toString() {
		return "DefColumnCfg [columnName=" + columnName + ", columnType=" + columnType + ", name=" + name + ", length=" + length + ", nullable="
				+ nullable + ", isTransient=" + isTransient + ", searchColumn=" + searchColumn + ", listColumn=" + listColumn + ", submitColumn="
				+ submitColumn + ", hiddenColumn=" + hiddenColumn + ", comment=" + comment + ", entityCfg=" + entityCfg + "]";
	}

}
